#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>

// 点分十进制IP地址与32位长整数之间的转换
int main(int argc, char *argv[])
{
    char ip_str[] = "172.18.11.100";
    struct in_addr ip;
    struct in_addr *ipptr;
    ipptr = &ip;
    ip.s_addr = 123456789UL;
    printf("IP:%s--->uint32 number: %ld\n", ip_str,inet_addr(ip_str));
    printf("uint32 number:%ld--->IP:%s\n",ip.s_addr,inet_ntoa(ip));
    if(inet_aton(ip_str,ipptr) == 0)
    {
        printf("inet_aton() error!\n");
        exit(1);
    }

    printf("IP:%s--->uint32 number: %ld\n", ip_str,inet_addr(ip_str));

    return 0;
}
